import org.junit.Test;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.Scanner;

public class IdTest {
    private long[] birth;

    public int parseId(String id) {
        String idRegex = "^\\d{17}[0-9Xx]$";
        if (!id.matches(idRegex)) {
            throw new RuntimeException("身份证格式不正确");
        }
        String birth = id.substring(6, 14);
        LocalDate birthDate = null;
        LocalDate now = LocalDate.now();
        int age = now.getYear() - birthDate.getYear();
        if (now.getMonthValue() < birthDate.getMonthValue()) {
            age--;
        } else if (now.getMonthValue() == birthDate.getMonthValue()) {

            if (now.getDayOfMonth() < birthDate.getDayOfMonth()) {
                age--;
            }
        }

        return age;
    }





    }
